package com.uzai.console.web.cms;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.cms.tbgoods.CmsMerTbGoodsInfoListDto;
import com.uzai.console.dto.cms.tbgoods.CmsMerTbGoodsQuery;
import com.uzai.console.dto.cms.tbgoods.CmsTbGoodsQuery;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.cms.CmsTbGoodsService;
import com.uzai.console.vo.base.SelectIdVo;
import com.uzai.console.vo.cms.tbgoods.CmsMerTbGoodsInfoVo;
import com.uzai.console.vo.cms.tbgoods.CmsTbGoodsInfoVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * CMS淘宝商品管理
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "淘宝商品",tags = "CMS小程序|淘宝商品")
@ApiSort(7)
@RestController
public class CmsTbGoodsController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(CmsTbGoodsController.class);

    @Autowired
    private CmsTbGoodsService cmsTbGoodsService;

    @ApiOperation(value = "淘宝商品超级搜索", notes = "淘宝商品超级搜索", response = CmsTbGoodsInfoVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/cmsTbGoods/findCmsTbGoodsList_superSearch")
    public Object findCmsTbGoodsList_superSearch(@RequestBody CmsTbGoodsQuery cmsTbGoodsQuery){
        return cmsTbGoodsService.findCmsTbGoodsList_superSearch(cmsTbGoodsQuery);
    }

    @ApiOperation(value = "查询淘宝商品一级类目", notes = "查询淘宝商品一级类目", response = SelectIdVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/cmsTbGoods/findCmsTbGoodsFirstTypeList")
    public Object findCmsTbGoodsFirstTypeList(){
        return cmsTbGoodsService.findCmsTbGoodsFirstTypeList();
    }

    @ApiOperation(value = "淘宝商品按分类搜索", notes = "淘宝商品超级搜索", response = CmsTbGoodsInfoVo.class)
    @ApiOperationSupport(order = 3)
    @PostMapping("/cmsTbGoods/findCmsTbGoodsList_typeSearch")
    public Object findCmsTbGoodsList_typeSearch(@RequestBody CmsTbGoodsQuery cmsTbGoodsQuery){
        return cmsTbGoodsService.findCmsTbGoodsList_typeSearch(cmsTbGoodsQuery);
    }

    @ApiOperation(value = "查询运营商配置的淘宝商品信息", notes = "查询运营商配置的淘宝商品信息", response = CmsMerTbGoodsInfoVo.class)
    @ApiOperationSupport(order = 4)
    @PostMapping("/cmsTbGoods/findCmsMerTbGoodsList")
    public Object findCmsMerTbGoodsList(@RequestBody CmsMerTbGoodsQuery cmsMerTbGoodsQuery){
        return cmsTbGoodsService.findCmsMerTbGoodsList(cmsMerTbGoodsQuery);
    }

    @SystemLogType(model = SystemModelEnum.CmsTbGoods, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "编辑运营商配置的淘宝商品信息", notes = "编辑运营商配置的淘宝商品信息")
    @ApiOperationSupport(order = 5)
    @PostMapping("/cmsTbGoods/updateCmsMerTbGoods")
    public Object updateCmsMerTbGoods(@RequestBody CmsMerTbGoodsInfoListDto cmsMerTbGoodsInfoListDto){
        cmsTbGoodsService.updateCmsMerTbGoods(cmsMerTbGoodsInfoListDto);
        return true;
    }

}
